<?php

namespace App\Containers\AppSection\Project\UI\API\Transformers;

use App\Containers\AppSection\File\UI\API\Transformers\FileTransformer;
use App\Containers\AppSection\Project\Models\Company;
use App\Ship\Parents\Transformers\Transformer;
use League\Fractal\Resource\Item;

class CompanyTransformer extends Transformer
{
    protected array $defaultIncludes = [
        'logo'
    ];

    /**
     * @var  array
     */
    protected array $availableIncludes = [

    ];

    public function transform(Company $t): array
    {
        return [
            'object' => $t->getResourceKey(),
            'include' => $this->getAvailableIncludes(),
            'id' => $t->getHashedKey(),
            'finance_type' => $t->finance_type,
            'finance' => $t->finance,
            'structure_details' => $t->structure_details,
            'persons_information' => $t->persons_information,
            'revenue' => $t->revenue,
            'primary_occupation' => $t->primary_occupation,
            'additional_facts' => $t->additional_facts,
            'foundation_year' => $t->foundation_year,
            'site' => $t->site,
            'no_site' => $t->no_site,
        ];
    }

    public function includeLogo(Company $t): ?Item
    {
        return $this->nullableItem($t->logo, new FileTransformer);
    }
}
